package org.dwell.nutzcow.test;

import org.dwell.nutzcow.domain.FileResource;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Jange on 2016/4/20.
 */
public class FileResourceDB {

    private static List<FileResource> fileResourceList = new ArrayList<FileResource>();

    static {
        fileResourceList.add(new FileResource("CHUD", "Folder" ,"" , "2", null));
        fileResourceList.add(new FileResource("amber", "Folder" ,"" , "2-1", "2"));
        fileResourceList.add(new FileResource("AmberTraceFormats.pdf", "file" ,"124.46 KB" , "2-1-1", "2-1"));
    }

    public static List<FileResource> getTops() {
        List<FileResource> returnList = new ArrayList<FileResource>();
        for (FileResource resource : fileResourceList) {
            if (resource.getDataTTParentId() == null || resource.getDataTTParentId().equals("")) {
                returnList.add(resource);
            }
        }
        return returnList;
    }

    public static List<FileResource> getChildren(String parentId) {
        List<FileResource> returnList = new ArrayList<FileResource>();
        for (FileResource resource : fileResourceList) {
            if (resource.getDataTTParentId() != null && resource.getDataTTParentId().equals(parentId)) {
                returnList.add(resource);
            }
        }
        return returnList;
    }


}
